package suncertify.db;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * Helper to copy the original db-File to the working Path
 * 
 * @author Alessandra
 *
 */
public class FileHelper {

    private static final String SOURCE_PATH = "D:\\Entwicklung\\SCJD\\Certification\\Aufgabe\\db-1x1.db";
    private static final String TARGET_PATH = "D:\\Entwicklung\\SCJD\\Certification\\Aufgabe\\File\\db-1x1.db";

    /**
     * copies the file from the source path to the target path
     * @throws IOException
     */
    public void copyOrigFile() throws IOException {
	FileChannel inChannel = new FileInputStream(SOURCE_PATH).getChannel();
	FileChannel outChannel = new FileOutputStream(TARGET_PATH).getChannel();
	try {
	    inChannel.transferTo(0, inChannel.size(), outChannel);
	} catch (IOException e) {
	    throw e;
	} finally {
	    if (inChannel != null)
		inChannel.close();
	    if (outChannel != null)
		outChannel.close();
	}
    }

}
